package com.mrd.gtimpframe.service.impl;

import com.mrd.gtimpframe.entity.TGenComContact;
import com.mrd.gtimpframe.repository.TGenComContactMapper;
import com.mrd.gtimpframe.service.TGenComContactService;
import com.mrd.util.KeyGenerator;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TGenComContactServiceImpl implements TGenComContactService {
    @Autowired
    TGenComContactMapper tGenComContactMapper;

    @Override
    @Transactional
    public int deleteByPrimaryKey(Object id){
        return tGenComContactMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional
    public int insert(TGenComContact t){
        if (StringUtils.isEmpty(t.getComContactId())) {
            t.setComContactId(KeyGenerator.generateRadomSequenceNo(""));
        }
        return tGenComContactMapper.insert(t);
    }

    @Override
    @Transactional
    public int insertSelective(TGenComContact t){
        return tGenComContactMapper.insertSelective(t);
    }

    @Override
    public TGenComContact selectByPrimaryKey(Object id){
        return tGenComContactMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional
    public int updateByPrimaryKeySelective(TGenComContact t){
        return tGenComContactMapper.updateByPrimaryKeySelective(t);
    }

    @Override
    @Transactional
    public int updateByPrimaryKey(TGenComContact t){
        return tGenComContactMapper.updateByPrimaryKey(t);
    }

    /**
     * 查询列表
     * @author han
     * @param tGenComContact
     * @return
     */
    @Override
    public List<TGenComContact> queryList(TGenComContact tGenComContact){
        return tGenComContactMapper.queryList(tGenComContact);
    }

    /**
     * 批量删除联系人
     * @author han
     * @param id 多个主键
     * @return
     */
    @Override
    @Transactional
    public int deleteBatch(Object[] id) {
        return tGenComContactMapper.deleteBatch(id);
    }

    /**
     * 根据委托关系主键删除联系人
     * @author han
     * @param arefId
     */
    @Override
    @Transactional
    public void deleteByArefId(String arefId){
        tGenComContactMapper.deleteByArefId(arefId);
    }
}
